//
//  HQYHomeKeyEyesModel.m
//  Go!
//
//  Created by rimi on 16/7/11.
//  Copyright © 2016年 黄秋燕. All rights reserved.
//

#import "HQYHomeKeyEyesModel.h"
#import "NetWorkManager.h"

@interface HQYHomeKeyEyesModel ()
@property (nonatomic, strong) NSMutableArray *dataSourceArray; /**< 数据源 */
@end

@implementation HQYHomeKeyEyesModel

- (void)getList {
    // 改变self的弱引用
    __weak typeof(self) weakSelf = self;
    
    // 获取团单网络请求
    [NetWorkManager getWithURL:@"searchdeals" urlParam:@{@"city_id":[[NSUserDefaults standardUserDefaults] objectForKey:currentCity_ID]} successBlock:^(id responseObject) {
        weakSelf.response = responseObject[@"data"][@"deals"];
    } FailureBlock:nil];
}

/**< 返回数据的组数*/
- (NSInteger)getNumberOfRows {
    return self.dataSourceArray.count;
}

- (NSArray *)getDataArray {
    _dataSourceArray = [NSMutableArray array];
    NSArray *array = self.response;
    for (NSInteger index = 0; index < array.count; index ++) {
        NSDictionary *dictM = @{@"icon":array[index][@"image"], @"description":array[index][@"title"], @"url":array[index][@"deal_murl"], @"name":array[index][@"title"], @"price": [NSString stringWithFormat:@"%.2f",([array[index][@"promotion_price"] floatValue] / 100)]};
        [_dataSourceArray addObject:dictM];
    }
    return [_dataSourceArray copy];
}




@end
